import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:geomancy/enums/index.dart';
import 'package:geomancy/styles/index.dart';
import 'package:geomancy/tools/constant.dart';
import 'package:geomancy/tools/utils.dart';
import 'package:geomancy/widgets/common_btn.dart';
import 'package:geomancy/widgets/common_header.dart';
import 'package:geomancy/widgets/common_room_position_tips.dart';
import 'package:geomancy/widgets/common_station_position_tips.dart';
import 'package:geomancy/widgets/common_text.dart';
import 'package:geomancy/widgets/common_title.dart';
import 'package:go_router/go_router.dart';

class PositionTipsPage extends StatefulWidget {
  final PositionTipsSource source;
  final String? birthday;
  const PositionTipsPage({super.key, required this.source, this.birthday});

  @override
  State<PositionTipsPage> createState() => _PositionTipsPageState();
}

class _PositionTipsPageState extends State<PositionTipsPage> {

  backHandle() {
    context.pop();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CommonHeader.appBar(context: context),
      backgroundColor: ColorStyle.pageDefaultColor,
      body: ListView(
        padding: EdgeInsets.fromLTRB(Constant.PAGEPADDING.w, 20.w, Constant.PAGEPADDING.w, 80.w),
        children: [
          const CommonTitleWidget(txt: '房间'),
          Container(
            height: 935.w,
            margin: EdgeInsets.only(top: 20.w, bottom: 96.w),
            padding: EdgeInsets.only(top: 26.w),
            decoration: BoxDecoration(
                color: ColorStyle.themeLightColor,
                border: Border.all(width: 5.w, color: ColorStyle.borderColor),
                borderRadius: BorderRadius.all(Radius.circular(60.w))
            ),
            child: Stack(
              children: [
                const Align(
                  alignment: Alignment.topCenter,
                  child: CommonRoomPositionTipsWidget(),
                ),
                Positioned(
                  bottom: 165.w,
                  left: 75.w,
                  child: CommonBtnWidget(txt: '开始', size: Size(510.w, 80.w), onTap: () {
                    Utils.shake();
                    CompassSource? s;
                    if (widget.source == PositionTipsSource.wealth) {
                      s = CompassSource.roomWealth;
                    } else if (widget.source == PositionTipsSource.study) {
                      s = CompassSource.roomStudy;
                    } else if (widget.source == PositionTipsSource.relations) {
                      s = CompassSource.roomRelations;
                    }
                    if (s != null) {
                      context.push('/start_compass', extra: {
                        "source": s,
                        "birthday": widget.birthday
                      });
                    }
                  }),
                ),
                Positioned(
                  bottom: -5.w,
                  left: -5.w,
                  right: -5.w,
                  child: Container(
                    height: 120.w,
                    padding: EdgeInsets.symmetric(horizontal: 40.w),
                    alignment: Alignment.center,
                    decoration: BoxDecoration(
                        color: ColorStyle.themeLightColor,
                        border: Border.all(width: 5.w, color: ColorStyle.borderColor),
                        borderRadius: BorderRadius.all(Radius.circular(60.w))
                    ),
                    child: CommonText(
                      txt: '请按上图所示，站在空间平面几何中心点，面向入户门，保持手机顶部与户门平行，将手机平置。',
                      fontSize: 24.sp,
                    ),
                  ),
                ),
              ],
            ),
          ),
          const CommonTitleWidget(txt: '工位'),
          Container(
            height: 935.w,
            margin: EdgeInsets.only(top: 20.w),
            padding: EdgeInsets.only(top: 50.w),
            decoration: BoxDecoration(
                color: ColorStyle.themeLightColor,
                border: Border.all(width: 5.w, color: ColorStyle.borderColor),
                borderRadius: BorderRadius.all(Radius.circular(60.w))
            ),
            child: Stack(
              children: [
                const Align(
                  alignment: Alignment.topCenter,
                  child: CommonStationPositionTipsWidget(),
                ),
                Positioned(
                  bottom: 165.w,
                  left: 75.w,
                  child: CommonBtnWidget(txt: '开始', size: Size(510.w, 80.w), onTap: () {
                    Utils.shake();
                    CompassSource? s;
                    if (widget.source == PositionTipsSource.wealth) {
                      s = CompassSource.stationWealth;
                    } else if (widget.source == PositionTipsSource.study) {
                      s = CompassSource.stationStudy;
                    } else if (widget.source == PositionTipsSource.relations) {
                      s = CompassSource.stationRelations;
                    }
                    if (s != null) {
                      context.push('/start_compass', extra: {
                        "source": s,
                        "birthday": widget.birthday
                      });
                    }
                  }),
                ),
                Positioned(
                  bottom: -5.w,
                  left: -5.w,
                  right: -5.w,
                  child: Container(
                    height: 120.w,
                    padding: EdgeInsets.symmetric(horizontal: 40.w),
                    alignment: Alignment.center,
                    decoration: BoxDecoration(
                        color: ColorStyle.themeLightColor,
                        border: Border.all(width: 5.w, color: ColorStyle.borderColor),
                        borderRadius: BorderRadius.all(Radius.circular(60.w))
                    ),
                    child: CommonText(
                      txt: '请按上图所示，背对办公桌，保持手机顶部与桌子长边平行，将手机平置。',
                      fontSize: 24.sp,
                    ),
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
